#include<bits/stdc++.h>
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define debug  freopen("in.txt","r",stdin),freopen("out.txt","w",stdout);
#define fs first
#define sc second
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int maxn = 1e6+10;
using namespace std;

int A,B,ans;
int main(){
	// debug;
	ios;

	cin>>A>>B;
	while(A>B){
		if(A%2 == 0) A/=2;
		else A++;
		ans++;
	}
	cout<<ans + B-A<<'\n';

	
	return 0;
}
